package thesis.filesharing.bo.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import thesis.filesharing.bo.ExerciseBO;
import thesis.filesharing.dao.ExerciseDAO;
import thesis.filesharing.model.Exercise;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@Service
public class ExerciseBOImpl implements ExerciseBO {
	
	@Autowired
	private ExerciseDAO exerciseDAO;
	
	@Override
	public Exercise saveExercise(Exercise exercise, String key, List<String> tags) {
		Key classKey = KeyFactory.stringToKey(key);
		return exerciseDAO.saveExercise(exercise, classKey, tags);
	}

	@Override
	public Exercise findExerciseById(Key exerciseKey) {
		return exerciseDAO.findExerciseById(exerciseKey);
	}

	@Override
	public List<Exercise> listExercisesOfClass(Key classKey, String exerciseType) {
		return exerciseDAO.listExercisesOfClass(classKey, exerciseType);
	}
}
